package org.jeecg.api.query;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.Map;

/**
 * elasticsearch查询条件
 *
 * @author ZhangYu
 * @date 2024/9/13 15:07
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ElasticsearchQuery {

    /**
     * ==字符
     */
    public static final String EQ = "==";

    /**
     * 所有的查询条件集合
     */
    private Map<String, Map<Object, Object>> allMap = new HashMap<>();

    /**
     * ==条件的字段
     */
    private Map<Object, Object> eqFieldMap = new HashMap<>();

    public <F, V> ElasticsearchQuery eq(F field, V value) {
        eqFieldMap.put(field, value);
        allMap.put(EQ, eqFieldMap);
        return this;
    }

}
